import { auditManageConst } from "src/consts/audit_manage_const";
import { PopupName } from "src/consts/popup_const";
import * as Api from 'src/api/net';

const state: any = {};


state.nodes = [];
state.status = "";
state.remark = "";
state.model = "";
state.id = "";
state.index = "";
state.complete_time = "";
state.create_time = "";

// vuex

/** 更新数据的 */
const mutations = {
    [auditManageConst.CommitAuditMStatus](state: any, data: any): void {
        console.log("auditM_status data update", data);
        state.nodes = data.nodes;
        state.status = data.status;
        state.remark = data.remark;
        state.model = data.model;
        state.id = data.id;
        state.index = data.index;
        state.complete_time = data.complete_time;
        state.create_time = data.create_time;
        WLLib.panel(PopupName.AuditM_Status);
    },
}

//异步处理
const actions = {
    [auditManageConst.DispatchAuditMStatus](context: VuexData, data?: any): void {
        var sendData: any = {}
        sendData.entity_id = data.entity_id
        sendData.model = data.model

        Api.AjaxPost(Config.ajaxUrl + "/webaudit/audit/view.do", sendData, (res: any) => {
            if (isNoEmptyObject(res.data)) {
                var resData: any = res.data
                resData.index = data.ind
                WLCommit(auditManageConst.CommitAuditMStatus, resData);
            }
        })
    },
}

export default {
    state,
    mutations,
    actions
}